package org.example.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.example.entity.DishEntity;

import org.example.mapper.DishMapper;
import org.example.service.DishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class DishServiceImpl implements DishService {


    @Autowired
    DishMapper dishMapper;

    @Override
    public IPage<DishEntity> getDishList(int pageNum, int pageSize) {
        Page<DishEntity> page = Page.of(pageNum,pageSize);
        QueryWrapper<DishEntity> queryWrapper = new QueryWrapper<>();

        IPage<DishEntity> dishEntityPage = dishMapper.selectPage(page, queryWrapper);
        log.info("Total recoder" + dishEntityPage.getTotal());
        log.info("Total Pages" + dishEntityPage.getPages());
        return dishEntityPage;
    }
}
